//package com.sunyard.springcloudhystrix.Hystrix;
//
//import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
//import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
//import org.springframework.stereotype.Service;
//
///**
// * @author zyl
// * @description
// * @since 2025/7/14
// */
//@Service
//public class OrderService {
//    // 模拟订单服务调用（失败率30%）
//    @HystrixCommand(
//            fallbackMethod = "getOrderFallback",
//            commandProperties = {
//                    @HystrixProperty(name = "circuitBreaker.enabled", value = "true"),
//                    @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "5"),
//                    @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "10000")
//            }
//    )
//    public String getOrder(String orderId) {
//        if (Math.random() < 0.3) {
//            throw new RuntimeException("Order Service Failed!");
//        }
//        return "Order-" + orderId;
//    }
//
//    // 降级方法
//    public String getOrderFallback(String orderId) {
//        return "[Fallback] Cached Order-" + orderId;
//    }
//}
